import Vue from 'vue'
import App from './App'
import uView from "uview-ui";
import store from './store'
import request from './common/request.js'
import api from './api/index.js'
import url from './common/config.js'

Vue.prototype.$store = store
Vue.config.productionTip = false
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
	import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
Vue.use(uView);
Vue.prototype.$request = request
Vue.prototype.$api = api
Vue.prototype.$url = url
Vue.prototype.$getDefaultRegions=async ()=>{
		try{
			let address=uni.getStorageSync('address')	
			let address_id=uni.getStorageSync('address_id')	
			if(!address||!address_id){
				api.getDefaultRegions().then(res=>{
				console.log(11,res)
				let	address=res.data.name
				let	address_id=res.data.id
				uni.setStorageSync('address',address)
				uni.setStorageSync('address_id',address_id)
				return {address,address_id}
				})
			}
				return {address,address_id}
		}catch(error){
			console.log('调用失败')
		}
}
Vue.prototype.$toutiao=(event_type)=>{
	let app=getApp()
	console.log('toutiao')
	
	let clickId=app.globalData.toutiao.clickid
	console.log(clickId)
	if(clickId){
		/* uni.request({
			url:"https://ad.toutiao.com/track/activate/?callback="+clickId+"&event_type="+event_type,
			method:"GET"
		}).then(res=>{
			console.log(res)
		}) */
		api.toutiao({callback:clickId,event_type:event_type})
	}

}
Vue.component('mescroll-body', MescrollBody)
Vue.component('mescroll-uni', MescrollUni)
App.mpType = 'app'

const app = new Vue({
	...App,
	store,

})
app.$mount()
